<template>
  <div class="need-know">
    <div class="left">
      <h1 class="know-title">在使用前还需了解：</h1>
      <img class="know-img" src="@/assets/img/faqq.png" />
    </div>
    <div class="right">
      <dl>
        <template v-for="(item, index) in needknow" :key="index">
          <dd class="right-item">
            <div class="fa" @click="change(index)">
              <p class="mtit">
                <img src="@/assets/img/faq.png" class="qa" />
                <span class="text">{{ item.title }}</span>
              </p>
              <img
                src="@/assets/img/arrow.png"
                class="arrow"
                v-bind:class="[isActive == index ? 'active' : '']"
              />
            </div>
            <p class="fq" v-bind:class="[isActive == index ? 'active' : '']" @click="change(index)">
              {{ item.content }}
            </p>
          </dd>
        </template>
        <dd class="right-item"></dd>
      </dl>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { needknow } from '@/global/constants'
import { ref } from 'vue'

let isActive = ref(-1)
const change = (index: any) => {
  if (index == isActive.value) {
    isActive.value = -1
  } else {
    isActive.value = index
  }
}
</script>

<style lang="less" scoped>
.need-know {
  display: flex;
  box-sizing: border-box;
  padding: 120px 0;
  justify-content: center;
  background-color: #f7fbff;
  .left {
    .know-title {
      font-size: 36px;
      font-weight: 600px;
      margin-bottom: 24px;
    }
    .know-img {
      width: 234px;
      height: 108px;
    }
  }
  .right {
    .right-item {
      width: 780px;
      border-top: 1px solid #e7e8e9;
      margin-left: 40px;
      padding: 0 32px;
      .fa {
        display: flex;
        -webkit-box-align: center;
        -webkit-align-items: center;
        -ms-flex-align: center;
        align-items: center;
        -webkit-box-pack: justify;
        -webkit-justify-content: space-between;
        -ms-flex-pack: justify;
        justify-content: space-between;
        min-height: 84px;
        cursor: pointer;
        .mtit {
          display: -webkit-box;
          display: -webkit-flex;
          display: -ms-flexbox;
          display: flex;
          -webkit-box-align: center;
          -webkit-align-items: center;
          -ms-flex-align: center;
          align-items: center;
          .qa {
            width: 20px;
            height: 20px;
            margin-right: 16px;
          }
          .text {
            font-size: 20px;
            color: #2e3034;
            font-weight: 600;
          }
        }
        .arrow {
          width: 14px;
          transition: transform 0.5s ease;
        }
        .active {
          transform: rotate(180deg);
        }
      }
      .fq {
        font-size: 16px;
        color: #2e3034;
        line-height: 32px;
        font-weight: 400;
        padding: 24px 28px;
        margin: 0 -30px;
        background: #fff;
        border-top: 1px dashed #e7e8e9;
        display: none;
        cursor: pointer;
      }
      .active {
        display: block;
      }
    }
  }
}
</style>
